#!/usr/bin/env bash

# Test HTTP backend with explicit format parameter
# This simulates tools without proper file extensions

# Test 1: Explicit format with tar.gz
cat <<EOF >mise.toml
[tools."http:hello-format"]
version = "1.0.0"
url = "https://mise.jdx.dev/test-fixtures/test-fixtures_hello-world-1.0.0-tarball"
format = "tar.gz"
bin_path = "hello-world-1.0.0/bin"
postinstall = "chmod +x \$MISE_TOOL_INSTALL_PATH/hello-world-1.0.0/bin/hello-world"
EOF

mise install -v
mise env
assert_contains "mise x -- hello-world" "hello world"

# Test 2: Platform-specific format
cat <<EOF >mise.toml
[tools."http:hello-format-platform"]
version = "1.0.0"
bin_path = "hello-world-1.0.0/bin"
postinstall = "chmod +x \$MISE_TOOL_INSTALL_PATH/hello-world-1.0.0/bin/hello-world"

[tools."http:hello-format-platform".platforms]
darwin-arm64 = { url = "https://mise.jdx.dev/test-fixtures/test-fixtures_hello-world-1.0.0-tarball", format = "tar.gz" }
darwin-amd64 = { url = "https://mise.jdx.dev/test-fixtures/test-fixtures_hello-world-1.0.0-tarball", format = "tar.gz" }
linux-amd64 = { url = "https://mise.jdx.dev/test-fixtures/test-fixtures_hello-world-1.0.0-tarball", format = "tar.gz" }
linux-arm64 = { url = "https://mise.jdx.dev/test-fixtures/test-fixtures_hello-world-1.0.0-tarball", format = "tar.gz" }
EOF

mise install
assert_contains "mise x -- hello-world" "hello world"
